#ifndef _common_h_
#define _common_h_

#include <stdio.h>
#include <assert.h>
#include "errno.h"

#define	WORD_SIZE	32
#define	DWORD_SIZE	64;
/* data type */
typedef	unsigned long long	u64;
typedef	signed long long	s64;
typedef	unsigned int		u32;
typedef	unsigned short		u16;
typedef	unsigned char		u8;
typedef	signed int		s32;
typedef	signed short		s16;
typedef	signed char		s8;

typedef	u32			word;

#define	SIGN(X,N)	((X)>>(N) & 0x1)

/*-------------------------------------------------------*/
/*! Bit Manipulation                                     */
/*-------------------------------------------------------*/
#define SEXT(i,n) ((signed)(((unsigned)(i))<<(32-(n)))>>(32-(n)))
#define	ZEXT(i,n) ((unsigned)(i))
#define SUBBITS(a,i,j) (((unsigned)(a)<<((WORD_SIZE-1)-(i)))>>((WORD_SIZE-1)-(i)+(j)))
#define	BIT(a,i)  (SUBBITS((a),(i),(i))&0x1)

#ifdef	TRACE
#define TRACE1(s)	__log__(__FILE__, __LINE__, s)
#define	TRACE2(s, ...)	__log__(__FILE__, __LINE__, s, __VA_ARGS__)
#else
#define TRACE1(s)	((void)0)
#define TRACE2(s, ...)	((void)0)
#endif

#endif /* _common_h_ */
